$(document).ready(function($){
        $('#mainlayer').dcMegaMenu({
                rowItems: '2',
                speed: 'fast'
        });
        
        $('.mainnav').fadeIn();
        
        $('#slider1').bxSlider({
                pager: true,
                controls: false,
                pause: 7000,
                auto: true,
                autoDelay: 7000,
                autoHover: true
        });
        
        
        var reviewTrigger = $('#writeNewReview');
        $(reviewTrigger).each(function(index, el) {
            $(el).bind('click', function() {
               var reviewContainer = $('#reviewForm');
               var reviewTrigger = $('#writeNewReview');
               if($(reviewContainer).hasClass('show'))
               {
                   $(reviewContainer).removeClass('show');
                   $(reviewContainer).addClass('hide');
                   $(reviewContainer).slideUp();
               }
               else
               {
                   $(reviewContainer).removeClass('hide');
                   $(reviewContainer).addClass('show');
                   $(reviewContainer).slideDown();
                   $(reviewTrigger).hide();
               }
            });
        });
        
     $('#orderRemark').each(function() {
		$.data(this, 'default', this.value);
	}).focus(function() {
		if (!$.data(this, 'edited')) {
			this.value = "";
		}
	}).change(function() {
		$.data(this, 'edited', this.value != "");
	}).blur(function() {
		if (!$.data(this, 'edited')) {
			this.value = $.data(this, 'default');
		}
	}); 
        
        var sorter = $('select[name=psorting]');
        $(sorter).each(function(index, el) {
            $(el).bind('change', function() {
                var selected = el.options[el.selectedIndex].value;
                location.href = selected;
            });
        });
        
        var basketPopupCloser = $('.basketPopup .closer');
        $(basketPopupCloser).each(function(index, el) {
            $(el).bind('click', function() {
                var basketPopup = $('#modalbasketFlyout');
                $(basketPopup).fadeOut();
            });
        });
        
        $("img[rel]").overlay({
            mask: '#789'
        });
        
});// JavaScript Document